import request from '@/config/axios'

export interface Model {
  id: string
  username: string
  nickname: string
  deptId: string
  postIds: string[]
  email: string
  mobile: string
  gender: number
  avatar: string
  loginIp: string
  remark: string
  loginDate: Date
  createTime: Date
}

// 查询列表
export const getPage = (params: PageParam) => {
  return request.get({ url: import.meta.env.VITE_BASE_ROLE + '/userCenter/dept/staff/page.json', params })
}

// 查询详情
export const getById = (id: string) => {
  return request.get({ url: import.meta.env.VITE_BASE_ROLE + '/userCenter/dept/staff/getById.json?id=' + id })
}

// 修改
export const update = (data: Model) => {
  return request.put({ url: import.meta.env.VITE_BASE_ROLE + '/userCenter/dept/staff/update.json', data })
}

// 删除
export const del = (id: string) => {
  return request.delete({ url: import.meta.env.VITE_BASE_ROLE + '/userCenter/dept/staff/del.json?id=' + id })
}

// 导 出用户
export const exportUser = (params) => {
  return request.download({ url: import.meta.env.VITE_BASE_ROLE + '/userCenter/dept/staff/export', params })
}

// 下载用户导入模板
export const importUserTemplate = () => {
  return request.download({ url: import.meta.env.VITE_BASE_ROLE + '/userCenter/dept/staff/get-import-template' })
}

// 用户密码重 置
export const resetUserPwd = (id: string, password: string) => {
  const data = {
    id,
    password
  }
  return request.put({ url: import.meta.env.VITE_BASE_ROLE + '/userCenter/dept/staff/update-password', data: data })
}

// 获取用户精简信息列表
export const getSimpleUserList = (): Promise<Model[]> => {
  return request.get({ url: import.meta.env.VITE_BASE_ROLE + '/userCenter/dept/staff/arr.json' })
}
